
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<head>
<title>Market place</title>
</head>

<body>
	<ui:composition>
		<p:panel header="#{msgs.myShoppingCart}" style="width:100%">
			<h:outputText value="#{shoppingCartModel.requiredDate}"></h:outputText>
			<p:dataTable value="#{shoppingCartModel.basket}" var="orderDetail"
				sortBy="1" style="width:100%" rowClasses="oddRow, evenRow">
				<ui:remove>
					<p:columnGroup type="header">
						<p:row>
							<p:column rowspan="2" colspan="1" headerText="#{msgs.customer}" />
							<p:column rowspan="1" colspan="1" headerText="#{msgs.name}" />

							<p:column rowspan="1" colspan="1"
								headerText="#{userModel.authenticatedUser.lastName},#{userModel.authenticatedUser.firstName}" />

							<p:column rowspan="2" colspan="1" headerText="#{msgs.pickup}" />
							<p:column rowspan="1" colspan="1" headerText="#{msgs.location}" />

							<p:column rowspan="1" colspan="1"
								headerText="#{userModel.authenticatedUser.dropOffLocation.name}, #{userModel.authenticatedUser.dropOffLocation.address}" />
						</p:row>
						<p:row>
							<p:column rowspan="1" colspan="1" headerText="#{msgs.telephone}" />
							<p:column rowspan="1" colspan="1"
								headerText="#{userModel.authenticatedUser.telephone}" />
							<p:column rowspan="1" colspan="1"
								headerText="#{msgs.dateAndTime}" />
							<p:column rowspan="1" colspan="1"
								headerText="#{shoppingCartModel.requiredDate.dayOfWeekLabel} #{shoppingCartModel.requiredDate.dateLabel}" />
						</p:row>
					</p:columnGroup>
				</ui:remove>
				<p:column style="width:55px">
					<p:commandButton actionListener="#{shoppingCartModel.remove}"
						icon="delete" ajax="TRUE" update=":centerForm,:headerForm"
						immediate="true" style="width:40px;float:right">
						<f:setPropertyActionListener target="#{shoppingCartModel.remove}"
							value="#{orderDetail.product}"></f:setPropertyActionListener>
					</p:commandButton>
				</p:column>
				<p:column>
					<h:graphicImage library="images"
						value="../#{orderDetail.product.icon}32.png"></h:graphicImage>
					<h:outputLabel
						value="#{orderDetail.product.nameLabel} (#{orderDetail.product.specificationDescLabel})"></h:outputLabel>
				</p:column>
				<p:column>
					<h:outputLabel value="#{orderDetail.orderedPrice}">
						<f:convertNumber type="currency" currencySymbol="$"
							minFractionDigits="2" maxFractionDigits="2" />
					</h:outputLabel>
					<h:outputText value="/#{orderDetail.product.priceUnitLabel}"></h:outputText>
				</p:column>
				<p:column>
					<p:spinner id="orderedQuantity"
						value="#{orderDetail.orderedQuantity}" size="1" min="1"
						validator="#{validator.validateInventory}"
						rendered="#{shoppingCartModel.isCanConfirm}">
						<p:ajax event="change" update=":centerForm,:headerForm"></p:ajax>
						<f:attribute name="orderDetail" value="#{orderDetail}"></f:attribute>
					</p:spinner>
					<p:message for="orderedQuantity" />
					<p:spinner value="#{orderDetail.orderedQuantity}" stepFactor="1"
						rendered="#{!shoppingCartModel.isCanConfirm}">
						<p:ajax event="change" update=":centerForm,:headerForm"></p:ajax>
					</p:spinner>
					<h:outputText value="#{orderDetail.product.stockUnitLabel}"></h:outputText>
				</p:column>
				<ui:remove>
					<p:column>
						<h:outputText value="#{orderDetail.product.stockUnitLabel}"
							style="float:right"></h:outputText>
					</p:column>
				</ui:remove>
				<p:column>
					<h:outputText value="≈"
						rendered="#{!orderDetail.product.isCanCaculateExactAmount}"
						style="font:green;font-size:1.2em"></h:outputText>
					<h:outputLabel value="#{orderDetail.orderedSubTotal}"
						style="float:right">
						<f:convertNumber type="currency" currencySymbol="$"
							minFractionDigits="2" maxFractionDigits="2" />
					</h:outputLabel>
				</p:column>
				<p:column headerText="#{msgs.GST}"
					rendered="#{shoppingCartModel.order.isTaxable}">
					<h:outputLabel value="#{orderDetail.orderedGST}"
						rendered="#{orderDetail.isTaxable}" style="float:right">
						<f:convertNumber type="currency" currencySymbol="$"
							minFractionDigits="2" maxFractionDigits="2" />
					</h:outputLabel>
				</p:column>
				<p:column headerText="#{msgs.QST}"
					rendered="#{shoppingCartModel.order.isTaxable}">
					<h:outputLabel value="#{orderDetail.orderedQST}"
						rendered="#{orderDetail.isTaxable}" style="float:right">
						<f:convertNumber type="currency" currencySymbol="$"
							minFractionDigits="2" maxFractionDigits="2" />
					</h:outputLabel>
				</p:column>
				<p:column headerText="#{msgs.subtotal}"
					rendered="#{shoppingCartModel.order.isTaxable}">
					<h:outputLabel value="#{orderDetail.orderedSubTotalPlusTax}"
						style="float:right">
						<f:convertNumber type="currency" currencySymbol="$"
							minFractionDigits="2" maxFractionDigits="2" />
					</h:outputLabel>
				</p:column>


				<p:columnGroup type="footer">
					<p:row>
						<p:column colspan="3" footerText="#{msgs.total}"
							style="text-align:right">
							<h:outputText value="#{msgs.total}"></h:outputText>
						</p:column>
						<p:column colspan="1"
							footerText="#{shoppingCartModel.order.orderedQuantity}"
							style="text-align:right" />
						<p:column colspan="1"
							footerText="#{shoppingCartModel.order.orderedTotalAmountLabel}"
							style="text-align:right" />
						<p:column colspan="1"
							footerText="#{shoppingCartModel.order.orderedTotalGSTLabel}"
							style="text-align:right"
							rendered="#{shoppingCartModel.order.isTaxable}" />
						<p:column colspan="1"
							footerText="#{shoppingCartModel.order.orderedTotalQSTLabel}"
							style="text-align:right"
							rendered="#{shoppingCartModel.order.isTaxable}" />
						<p:column colspan="1"
							footerText="#{shoppingCartModel.order.orderedTotalPlusTaxLabel}"
							style="text-align:right"
							rendered="#{shoppingCartModel.order.isTaxable}" />
					</p:row>
					<p:row
						rendered="#{shoppingCartModel.customer.balance>0.01 and shoppingCartModel.order.isTaxable}">
						<p:column colspan="7" footerText="#{msgs.yourAccountCredit}"
							style="text-align:right"></p:column>
						<p:column colspan="1"
							footerText="#{shoppingCartModel.customer.balanceLabel}"
							style="text-align:right">
						</p:column>
					</p:row>
					<p:row
						rendered="#{shoppingCartModel.customer.balance>0.01 and !shoppingCartModel.order.isTaxable}">
						<p:column colspan="3" footerText="#{msgs.yourAccountCredit}"
							style="text-align:right"></p:column>
						<p:column colspan="3"
							footerText="#{shoppingCartModel.customer.balanceLabel}"
							style="text-align:right">

						</p:column>
					</p:row>
					<p:row rendered="#{shoppingCartModel.order.isTaxable}">
						<p:column colspan="7" footerText="#{msgs.charge}"
							style="text-align:right" />

						<p:column colspan="1"
							footerText="#{shoppingCartModel.totalChargeLabel}"
							style="text-align:right" />
					</p:row>
					<p:row rendered="#{ !shoppingCartModel.order.isTaxable}">
						<p:column colspan="3" footerText="#{msgs.charge}"
							style="text-align:right" />

						<p:column colspan="3"
							footerText="#{shoppingCartModel.totalChargeLabel}"
							style="text-align:right" />
					</p:row>
					<p:row
						rendered="#{shoppingCartModel.havePromotionReward and shoppingCartModel.order.isTaxable}">
						<p:column colspan="8"
							footerText="#{msgs.afterPayment}, #{msgs.youCanGet} #{shoppingCartModel.order.promotionRewardRateLabel} #{msgs.creditReward}"
							style="text-align:right" />
					</p:row>

					<p:row
						rendered="#{shoppingCartModel.havePromotionReward and !shoppingCartModel.order.isTaxable}">
						<p:column colspan="5"
							footerText="#{msgs.afterPayment}, #{msgs.youCanGet} #{shoppingCartModel.order.promotionRewardRateLabel} #{msgs.creditReward}"
							style="text-align:right" />
					</p:row>
				</p:columnGroup>
			</p:dataTable>
			<h:panelGrid columns="2" style="width:100%">
				<p:commandLink value="#{msgs.emptyCart}"
					update=":centerForm,:headerForm" ajax="TRUE" immediate="true"
					actionListener="#{shoppingCartModel.emptyBasket}"></p:commandLink>
				<p:commandLink value="#{msgs.continueShopping}" type="submit"
					immediate="true" action="/user/shopping.xhtml?faces-redirect=true"></p:commandLink>
			</h:panelGrid>
		</p:panel>
		<ui:include src="/components/public/shopping/promotionPanel.xhtml"></ui:include>
		<ui:include src="/components/public/shopping/prepaidRemindPanel.xhtml"></ui:include>

		<p:panel header="#{msgs.orderTips}" style="width:100%" rendered="#{shoppingCartModel.order.isHaveFrozenFood or !shoppingCartModel.isFreeDelivery}">
			<p:effect event="load" type="pulsate"></p:effect>
			<p:panelGrid columns="1">
				<p:outputLabel value="#{msgs.frozenFoodTips}"
					style="color:green; font-size:1.2em; font-style:italic;float:left"
					rendered="#{shoppingCartModel.order.isHaveFrozenFood}">
					<p:effect event="load" type="flash"></p:effect>
				</p:outputLabel>
				<h:outputFormat value="#{msgs.deliveryFeeTips}"
					style="color:green; font-size:1.2em; font-style:italic;float:left"
					rendered="#{!shoppingCartModel.isFreeDelivery}">
					<f:param
						value="#{shoppingCartModel.requiredWeek.freeDeliveryMinimumAmount}"></f:param>
					<f:param value="#{shoppingCartModel.requiredWeek.deliveryFee}"></f:param>
				</h:outputFormat>

			</p:panelGrid>
		</p:panel>
		<p:commandButton id="submitOrder" value="#{msgs.submitOrder}"
			type="submit" ajax="FALSE"
			title="#{msgs.customer}:#{shoppingCartModel.customer.lastName} #{shoppingCartModel.customer.firstName} #{msgs.requiredDate}:#{shoppingCartModel.requiredDate.dateLabel}"
			action="#{shoppingCartController.submitOrder}"
			disabled="#{shoppingCartModel.isBasketEmpty or (!shoppingCartModel.haveEnoughCredit and (shoppingCartModel.location.isPrepaid or shoppingCartModel.customer.isPrepaid))}"
			style="background:green; color:white;float:right;margin-top:20px">
		</p:commandButton>
	</ui:composition>
</body>

</html>


